package com.beiding.jsonanalyzer.analyze.func;

import com.beiding.jsonanalyzer.analyze.func.funckey.FuncAbleKey;
import com.beiding.jsonanalyzer.analyze.func.openfunc.Concat;
import com.beiding.jsonanalyzer.analyze.func.openfunc.KeySelfCase;
import com.beiding.jsonanalyzer.analyze.func.openfunc.Len;
import com.beiding.jsonanalyzer.analyze.func.openfunc.Split;
import com.beiding.jsonanalyzer.analyze.query.ComparatorResult;
import com.beiding.jsonanalyzer.analyze.query.SelfQueryGrammar;

/**
 * 自身
 *
 * @author 丁常磊
 * @date 2022/6/27 15:26
 */

public interface OneFunc<W extends FuncBase> extends SelfQueryGrammar, FuncFactory<W> {

    /**
     * 切分
     *
     * @param by
     * @return
     */
    default CollectionFunc split(String by) {
        return Split.of(this, by);
    }

    default OneFunc len() {
        return Len.of(this);
    }


    default OneFunc concat(Object v) {
        return Concat.of(this, v);
    }


    default KeySelfCase.CheckWhen when(FuncFactory<FuncBase<ComparatorResult>> whenQuery) {
        return KeySelfCase.of(this).when(whenQuery);
    }

    default KeySelfCase.CheckWhen when(Object whenValue) {
        return KeySelfCase.of(this).when(whenValue);
    }



    @Override
    default Object getSelf() {
        return this;
    }


}
